//
//  SPLiveDetailHeaderView.m
//  panzer
//
//  Created by 还带大道 on 2018/10/21.
//  Copyright © 2018年 还带大道. All rights reserved.
//

#import "SPLiveDetailHeaderView.h"
#import "SPCommon.h"
#import "SPLiveDetailModel.h"
#import "SPAnchorModel.h"

@interface SPLiveDetailHeaderView()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *ImageV;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UIImageView *sex_icon;
@property (weak, nonatomic) IBOutlet UILabel *money;
@property (weak, nonatomic) IBOutlet UILabel *count_newAdd;
@property (weak, nonatomic) IBOutlet UILabel *count_totalGuide;
@property (weak, nonatomic) IBOutlet UILabel *live_duration;
@property (weak, nonatomic) IBOutlet UILabel *number_sale;
@property (weak, nonatomic) IBOutlet UIButton *level;

@end

@implementation SPLiveDetailHeaderView

+ (instancetype)shareHeaderView
{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
}


- (void)awakeFromNib
{
    [super awakeFromNib];
    _bgView.backgroundColor = [UIColor whiteColor];

    _bgView.layer.shadowColor = RZ_COLOR_ALPHA(201, 201, 201, 0.37).CGColor;
    _bgView.layer.cornerRadius = 6;
    _bgView.layer.shadowOffset = CGSizeMake(0,1);//shadowOffset阴影偏移,x向右偏移，y向下偏移，默认(0, -3)
    _bgView.layer.shadowOpacity = 1;//阴影透明度，默认0
    _bgView.layer.shadowRadius = 4;//阴影半径，默认3
    
    _level.titleLabel.font = [UIFont systemFontOfSize:8];
    [_level setTitle:@"15" forState:UIControlStateNormal];
    _level.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    CGFloat offsetX = self.level.currentBackgroundImage.size.width*0.33;
    _level.titleEdgeInsets = UIEdgeInsetsMake(0,offsetX,0,0);
    
    _ImageV.layer.cornerRadius = 30.5;
    _ImageV.clipsToBounds = YES;
}


- (void)setModel:(SPLiveDetailModel *)model
{
    _model = model;
    SPAnchorModel *anchor = model.anchor_list.firstObject;
    [_ImageV sd_setImageWithURL:[NSURL URLWithString:anchor.avatar]];
    _name.text = anchor.nickname;
    _money.text = [NSString stringWithFormat:@"%ld元",model.actprice];
    _count_newAdd.text = [NSString stringWithFormat:@"%ld个",model.actcollen];
    _count_totalGuide.text = [NSString stringWithFormat:@"%ld人",model.total_man];
    _live_duration.text = [NSString stringWithFormat:@"%d小时",3];
    _number_sale.text = [NSString stringWithFormat:@"%d小件",20];
}
@end
